package pkg

import (
	"fmt"
	"net"
)

// AllIP4 AllIP4
func AllIP4() (data []string) {
	var err error
	defer func() {
		if err != nil {
			fmt.Println("获取本地IP失败=>", err)
		}
	}()
	var items []net.Addr
	items, err = net.InterfaceAddrs()
	if err != nil {
		return
	}
	data = make([]string, 0)
	for _, item := range items {
		n, ok := item.(*net.IPNet)
		if !ok {
			continue
		}
		ip := n.IP.To4()
		if ip == nil {
			continue
		}
		data = append(data, ip.String())
	}
	return
}
